package com.mall.huohuo.openapi.controller.home;

import com.mall.huohuo.process.NodeContext;
import com.mall.huohuo.process.engine.ProcessEngine;
import com.mall.huohuo.result.Result;
import com.mall.huohuo.service.home.domain.Banner;
import com.mall.huohuo.service.home.service.BannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.UUID;

@RestController
@RequestMapping("/home")
public class HomeController {
    @Autowired
    ProcessEngine processEngine;

    @Autowired
    BannerService bannerService;

    @GetMapping("/banners")
    public Result<List<Banner>> banners() {
        NodeContext nodeContext = new NodeContext();
        nodeContext.setProcessName("test")
                .setRequestId(UUID.randomUUID().toString())
                .setDataEntity("k1", "12223423");
        
        processEngine.process(nodeContext);

        return Result.success(bannerService.getBannerList());
    }


}
